/**
 * FileName: Handovers
 * Author:   秋水浮萍
 * Date:     2020/7/1 13:25
 * Description: 交接
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.crm.system.mapper;

import com.crm.model.HandoverName;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 〈一句话功能简述〉<br> 
 * 〈交接〉
 *
 * @author 秋水浮萍
 * @create 2020/7/1
 * @since 1.0.0
 */

@Repository
public interface SysHandovers {
    @Select("select sys_department.dep_name as depName,sys_user.true_name as trueName ,sys_user.user_id as userId  from sys_user left join sys_department on sys_user.dep_id =sys_department.id\n" +
            "where sys_user.disabled=0 and sys_user.role_id!='003' order BY sys_user.dep_id ")
    List<HandoverName> allName();

    @Update("<script>" +
            "UPDATE crm_partner set create_user_id= #{userId} ,update_time=#{updateTime} where partner_id in  " +
            "<foreach collection='userValue' item='id' open='(' separator=',' close=')'>" +
            " #{id}"+
            "</foreach>" +
            "</script>")
    int updateHandover(@Param("userValue") String[] userValue,String userId,String updateTime);

    @Update("UPDATE crm_partner set create_user_id =#{updateUserId} , update_time=#{updateTime}" +
            " WHERE create_user_id =#{createUserId}")
    int updateUserId(String updateUserId, String updateTime,String createUserId);
}
